import { type Persons, type PersonInter } from '@/types'
import { reactive, toRefs, withDefaults, defineProps } from 'vue'
export default function () {
  let person = reactive<PersonInter>({ name: 'person', age: 1, id: '101' })
  let personList = reactive<Persons>([
    { name: 'person1', age: 1, id: '101' },
    { name: 'person2', age: 2, id: '102' },
  ])
  const { name, id, age } = toRefs(person)
  // 限制类型+限制必要性+指定默认值+函数返回有对象
  /*  withDefaults(defineProps<{ list?: Persons; msg: string }>(), {
    list: () => [
      {
        name: 'a',
        age: 12,
        id: '1',
      },
    ],
  }) */
  return { person, name, id, age, personList }
}
